package com.jml.单例模式;

import com.jml.单例模式.反射破坏内部类.LazyInnerClassSingleton;

public class 双重检查 {
    private static 双重检查 doubleCheckSingle;

    private 双重检查() {
        //可以避免反射破坏
        if(doubleCheckSingle!=null){
            throw new RuntimeException("");
        }
    }
    public 双重检查 getInstance() {
        if (doubleCheckSingle == null) {
            synchronized (this) {
                if (doubleCheckSingle == null) {
                    doubleCheckSingle = new 双重检查();
                }
            }
        }
        return doubleCheckSingle;
    }
}
